using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_HeroUpdate : UIBaseNode
    {
        #region Template Generate,don't modify
        protected partial class UIB_UIN_HeroUpdate
        {
            #region ObjectBinding Generate
            public UnityEngine.GameObject upInfo { protected set; get; }
            public UnityEngine.GameObject rightInfo { protected set; get; }
            public UnityEngine.GameObject rightAwake { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<UnityEngine.GameObject>("upInfo", out var __tbv0);
                this.upInfo = __tbv0;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("rightInfo", out var __tbv1);
                this.rightInfo = __tbv1;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("rightAwake", out var __tbv2);
                this.rightAwake = __tbv2;
            }
            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields & properties
        private UIN_HeroUpInfo heroUpInfo = null;
        private UIN_HeroUpAwake heraUpAwake = null;

        private HeroData heroData;

        protected UIB_UIN_HeroUpdate ui { get; set; }
        #endregion

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_HeroUpdate();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {
            this.heroUpInfo = this.InitChildNode<UIN_HeroUpInfo>(this.ui.upInfo);
            this.heraUpAwake = this.InitChildNode<UIN_HeroUpAwake>(this.ui.rightAwake);
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        protected override void OnDispose()
        {
            this.heroUpInfo = null;
            this.heraUpAwake = null;
            this.heroData = null;
        }

        public void Show(HeroData data)
        {
            this.Show();
            this.heroData = data;
            this.ViewUp(heroData.isMaxLvCanAwaken);
        }

        public void ViewUp(bool isAwaken)
        {
            this.heraUpAwake.Hide();
            this.ui.rightInfo.SetActive(false);
            if (heroData == null)
                return;
            this.heroUpInfo.Show(heroData);
            if (isAwaken)
            {
                this.heraUpAwake.Show(heroData);
            }
            else
            {
                this.ui.rightInfo.SetActive(true);
            }
        }

        public void ViewDefault()
        {
            this.ViewUp(heroData.isMaxLvCanAwaken);
        }
    }
}
